package wibrst.utils{
	/**
	 * ...
	 * @author wibrst@qq.com
	 */
	public class VectorUtil {
		
		static public function concatNum( vcTo:Vector.<Number>, vcFrom:Vector.<Number> ):void {
			if ( vcTo && vcFrom && vcFrom.length ) {
				for ( var i:Number = 0; i < vcFrom.length; ++i ) {
					vcTo.push( vcFrom[i] );
				}
			}
		}
		
		static public function shuffle(vcOrig:*):void {
			for ( var i:Number = vcOrig.length - 1; i > -1; --i) {
				var r:Number = Math.floor( vcOrig.length * Math.random() );		/// produce random idx
				var tmp:Object = vcOrig[i]; vcOrig[i] = vcOrig[r]; vcOrig[r] = tmp;		/// swap element between thru idx and randm idx
			}
		}
		
		static public function getRdmElem( vcSrc:Vector.<*>, nStart:Number = 0, nEnd:Number = -1 ):* {
			if ( nEnd == -1 ) nEnd = vcSrc.length;
			
			var nLenValid:Number = nEnd - nStart;
			return vcSrc[ getRdmIdx( nLenValid, nStart ) ];
		}
		
		static public function getRdmIdx( nLen:Number, nBase:Number = 0 ):Number {
			return nBase + int( Math.random() * nLen );
		}
		
		static public function compNum( nA:Number, nB:Number ):Number {
			if ( nA == nB ) {
				return 0;
			}else if ( nA < nB ) {
				return -1;
			}else {
				return 1;
			}
		}
		
	}

}